

// 主题切换文件
export const setTheme = themeKey => {

  let KEY = "Light";
  if (themeKey) {
    KEY = themeKey;
  }

  let styleLink = document.getElementById('sub-theme-style');
  let hrefSrc = '/theme/normal.css';

  // 根据key 挂载不同主题
  if (KEY === 'Light') { // 默认主题
    // hrefSrc = '/theme/normal.css';
    hrefSrc = '';
  }

  if (KEY === 'Dark') { //暗黑主题
    // todo cdn 加速
    hrefSrc = '/sub-dark.css';
  }

  if (styleLink) {
    styleLink.href = hrefSrc;
  } else {
    styleLink = document.createElement('link');
    styleLink.type = 'text/css';
    styleLink.rel = 'stylesheet';
    styleLink.id = 'sub-theme-style';
    styleLink.href = hrefSrc;
    document.body.append(styleLink);
  }
};
